<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="/admin/common/css/style_sub.jsp"></jsp:include>
<title>字典FRAME</title>
<script type="text/javascript">
	if("${operResult}"=="true"){
		alert("操作成功");
	}
	function updateDicState(id,is_active){
		window.location="<%=basePath%>basic/sys/dic_updateDic.action?sysDictionary.id="+id+"&sysDictionary.is_active="+is_active+"&sysDictionary.typeid=${sysDictionary.typeid}";
	}
	function deleteDic(id){
		if(confirm("确定要删除此项吗？删除后不可恢复。")){
			window.location="<%=basePath%>basic/sys/dic_deleteDic.action?sysDictionary.id="+id+"&sysDictionary.typeid=${sysDictionary.typeid}";
		}
	}
</script>
</head>
<body>
	<div class="struRight">
		<div class="searchTab">
		<form action="<%=basePath%>basic/sys/dic_getDicByType.action" id="form" method="post">
			<table>
			
				<tr align="left">
					<th>字典代码</th>
					<td><input type="text" size="20" name="sysDictionary.key" value="${sysDictionary.key }"/></td>
					<th>字典描述</th>
					<td><input type="text" size="20" name="sysDictionary.context" value="${sysDictionary.context }"/>
						<input type="hidden" size="20" name="sysDictionary.typeid" value="${sysDictionary.typeid }"/>
					</td>
					<td colspan="3"><span class="btn"><input type="submit"
							value="查询" /></span> <span class="btn"><input type="button"
							value="添加" onclick="parent.editdic();" /></span></td>
				</tr>
			</table>
			</form>
		</div>
		<div class="listTab">
			<table>
				<thead>
					<tr>
						<td>ID</td>
						<td>类型</td>
						<td>字典代码</td>
						<td>字典值</td>
						<td title="描述过长时，只显示前10个字符。">描述</td>
						<td>创建人</td>
						<td>创建日期</td>
						<td>最后修改人</td>
						<td>最后修改时间</td>
						<td>启/停用</td>
						<td>参数种类</td>
						<td>操作</td>
					</tr>
				</thead>
				<tbody>
				<s:iterator value="%{dicList }">
					<tr>
						<td>${id }</td>
						<td>${typeName }</td>
						<td>${key }</td>
						<td>${value }</td>
						<td title="${context }">${fn:substring(context,1,10)}</td>
						<td>${createdOperName}</td>
						<td>
						<s:date name="created" format="yyyy-MM-dd" />
						</td>
						<td>${updatedOperName}</td>
						<td>
						<s:date name="updated" format="yyyy-MM-dd" />
						</td>
						<td>
							<s:if test="%{is_active==1}">
								<img src="<%=basePath%>style/icons/ok.png" title="启用" alt="启用"/>
							</s:if>
							<s:elseif test="%{is_active==0}">
								<img src="<%=basePath%>style/icons/pause.png" title="停用" alt="停用"/>
							</s:elseif>
						</td>
						<td>
							<s:if test="%{type==1}">
								系统内置
							</s:if>
							<s:elseif test="%{type==2}">
								用户定义
							</s:elseif>
						</td>
						<td><a href="javascript:void(0);" class="modi" onclick="parent.editdic(${id});">编辑</a>
						<s:if test="%{is_active==1}">
								<a href="javascript:void(0);" class="disc" onclick="updateDicState(${id}, 0);">停用</a>
							</s:if>
							<s:else>
								<a href="javascript:void(0);" class="enable" onclick="updateDicState(${id}, 1);">启用</a>
							</s:else>
					    <s:if test="%{type==2}">
					    	<a href="javascript:deleteDic(${id });" class="del">删除</a>
					    </s:if>
					    </td>
					</tr>
				</s:iterator>
				<s:if test="%{dicList.size()==0}">
					<tr><td colspan="20" class="failmsg"><font>暂未定义字典</font></td></tr>
				</s:if>
				</tbody>
			</table>
		</div>
	</div>
</body>
</html>